package com.hbnu.iostream;

import java.io.File;

/**
 * 需求：删除指定文件夹下的文件
 *
 * @author kittychen
 * @since 2025-10-10 16:53
 */
public class FileOperator02 {

    public static void main(String[] args) {
        String path = "C:" + File.separator + "Users" + File.separator + "Administrator" +
                File.separator + "Desktop" + File.separator + "kittychen" +
                File.separator + "class2311" + File.separator + "test.txt";

        File file = new File(path);

        if (file.exists()) {
            boolean result = file.delete();
            if (result) {
                System.out.println("文件删除成功");
            } else {
                System.out.println("文件删除失败");
            }
        } else {
            System.out.println("文件不存在");
        }
    }
}
